project(TST_LIB)

add_library(tst_native_lib SHARED tst_native_lib_impl.cpp)
target_include_directories(tst_native_lib PRIVATE
    ${ANI_INCLUDE_DIR}
    ${ANI_HELPERS_INCLUDE_DIR}
    ${PANDA_HELPERS_SOURCE_DIR}
)
target_link_libraries(tst_native_lib libani_helpers)

set(ARKTSCONFIG_PATH "${CMAKE_CURRENT_BINARY_DIR}/arktsconfig.json")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/arktsconfig.json.in" "${ARKTSCONFIG_PATH}")

compile_panda_source_list(
    TARGET_NAME tst_lib_abc
    ARKTSCONFIG "${ARKTSCONFIG_PATH}"
    SOURCE_LIST
        "TstLib.ets"
    EXTRA_DEPS
        measure_native_lib_srcs
        tst_native_lib
)

ark_aot(
    TARGET_NAME
        tst_lib_aot
    ABC_FILE
        "TstLib.abc"
    EXTRA_BOOT_PANDA_FILES
        ${MEASURE_NATIVE_LIB_BINARY_DIR}/MeasureNativeLib.abc
    EXTRA_DEPS
        tst_lib_abc
)

add_custom_target(tst_lib_srcs
    DEPENDS
        tst_lib_aot
        tst_lib_abc
)
